package cn.zqh.store.controller;


import cn.zqh.bean.api.CommonResult;
import cn.zqh.bean.bo.AdminChangeStore;
import cn.zqh.bean.bo.Pstore;
import cn.zqh.bean.bo.UserChangeStore;
import cn.zqh.store.service.StoreService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zqh
 * @since 2023-01-06
 */
@RestController
@RequestMapping("/store")
public class StoreController {


    @Autowired
    private StoreService storeService;

    /**
      * @Author: zqh
      * @Date:
      * @Description: 通过用户主键查询旗下的店铺
    */
    @ApiOperation(value = "通过用户id获取店铺")
    @GetMapping("/getStoreByUserId")
    public CommonResult QueryTheStoresUnderTheCompanyThroughTheUserPrimaryKey(String uid){
        return storeService.QueryTheStoresUnderTheCompanyThroughTheUserPrimaryKey(uid);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 添加一个新店铺
    */
    @ApiOperation(value = "添加一个新店铺")
    @PostMapping("AddANewStore")
    public CommonResult addAAewStore(@RequestBody Pstore pstore){
        return storeService.addAAewStore(pstore);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 查询所有店铺
    */
   @ApiOperation(value = "查询所有店铺")
   @GetMapping("getAllStore")
   public CommonResult getAllStore(){
       return storeService.getAllStore();
   }


   /**
     * @Author: zqh
     * @Date:
     * @Description: 通过店铺id获取店铺信息
   */
   @ApiOperation(value = "通过店铺id获取店铺信息")
   @GetMapping("getStoreInformationByStoreId")
    public CommonResult getStoreInformationByStoreId(String storeId){
       return storeService.getStoreInformationByStoreId(storeId);
   }

   /**
     * @Author: zqh
     * @Date:
     * @Description: 店主修改店铺信息
   */
   @ApiOperation(value = "店主修改店铺信息")
   @PostMapping("storeOwnerModifiesStoreInformation")
    public CommonResult storeOwnerModifiesStoreInformation(@RequestBody UserChangeStore userChangeStore){
       return storeService.storeOwnerModifiesStoreInformation(userChangeStore);
   }

   /**
     * @Author: zqh
     * @Date:
     * @Description: 管理员修改店铺信息
   */
   @ApiOperation(value = "管理员修改店铺信息")
   @PostMapping("adminModifiesStoreInformation")
    public CommonResult adminModifiesStoreInformation(@RequestBody AdminChangeStore adminChangeStore){
       return storeService.adminModifiesStoreInformation(adminChangeStore);
   }

   /**
     * @Author: zqh
     * @Date:
     * @Description: 删除店铺
   */
   @ApiOperation(value = "删除店铺")
   @DeleteMapping("delStoreById")
    public CommonResult delStoreById(String StoreId){
       return storeService.delStoreById(StoreId);
   }

}

